import { ApplicationContext, BeanInfo } from '../context/ApplicationContext'
import { BeanScope } from '../model/BeanScope'

export const Context = new ApplicationContext()

/**
 * <h2>修饰一个类</h2>
 * 声明当前类是一个小组件
 * @param name
 * @param scope 指定 Bean 类型, 单例 | 原型; 默认 单例(作用域单例)
 */
export function Component(name: string, scope: BeanScope = BeanScope.SINGLETON): ClassDecorator {
    return (target: any) => Context.registered(new BeanInfo(name, target, scope))
}
